package com.woniu.cinema.controller;

import java.util.List;

import com.woniu.cinema.vo.ActorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.Actor;
import com.woniu.cinema.service.ActorService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 演员信息Controller
 * 
 * @author yy
 * @date 2022-03-30
 */
@RestController
public class ActorController extends BaseController
{
    @Autowired
    private ActorService actorService;

    @RequestMapping("feign/cinema/actor/queryById")
    public List<Actor> queryById(@RequestParam("actorId")  Integer actorId)
    {
        List<Actor> list = actorService.queryById(actorId);
        return list;
    }
    
    
/**
 * 根据movieId查询演员列表
 * @author jitwxs
 * @date 2022/4/7 0007 10:52
 * @param movieId
 * @return com.woniu.common.core.domain.AjaxResult
 */
    @GetMapping("web/cinema/movieactor/queryActorsByMovieId")
    public AjaxResult queryActorsByMovieId(Integer movieId)
    {
        List<ActorVo> list = actorService.selectActorVoList(movieId);
        return AjaxResult.success("ok",list);
    }
    /**
     * 查询演员信息列表
     */
    @GetMapping("/cinema/actor/list")
    public TableDataInfo list(Actor actor)
    {
        startPage();
        List<Actor> list = actorService.selectActorList(actor);
        return getDataTable(list);
    }

    /**
     * 导出演员信息列表
     */
    @Log(title = "演员信息", businessType = BusinessType.EXPORT)
    @GetMapping("/cinema/actor/export")
    public AjaxResult export(Actor actor)
    {
        List<Actor> list = actorService.selectActorList(actor);
        ExcelUtil<Actor> util = new ExcelUtil<Actor>(Actor.class);
        return util.exportExcel(list, "actor");
    }

    /**
     * 获取演员信息详细信息
     */
    @GetMapping(value = "/cinema/actor/{actorId}")
    public AjaxResult getInfo(@PathVariable("actorId") Integer actorId)
    {
        return AjaxResult.success(actorService.selectActorById(actorId));
    }

    /**
     * 新增演员信息
     */
    @Log(title = "演员信息", businessType = BusinessType.INSERT)
    @PostMapping("/cinema/actor")
    public AjaxResult add(@RequestBody Actor actor)
    {
        return toAjax(actorService.insertActor(actor));
    }

    /**
     * 修改演员信息
     */
    @Log(title = "演员信息", businessType = BusinessType.UPDATE)
    @PutMapping("/cinema/actor")
    public AjaxResult edit(@RequestBody Actor actor)
    {
        return toAjax(actorService.updateActor(actor));
    }

    /**
     * 删除演员信息
     */
    @Log(title = "演员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/cinema/actor/{actorIds}")
    public AjaxResult remove(@PathVariable Integer[] actorIds)
    {
        return toAjax(actorService.deleteActorByIds(actorIds));
    }
}
